import Vue from "vue";
import VueI18n from "vue-i18n";

// 引入自定义语言配置

// 引入UI框架语言配置---elementui
import ElementLocale from "element-ui/lib/locale";
import enLocale from "element-ui/lib/locale/lang/en";
import zhLocale from "element-ui/lib/locale/lang/zh-CN";

import enPermission from "../ModulePermission/i18n/langs/en";
import zhPermission from "../ModulePermission/i18n/langs/zh";

import enSystem from "../ModuleSystem/i18n/langs/en";
import zhSystem from "../ModuleSystem/i18n/langs/zh";

import enWorkFlow from "../ModuleWorkFlow/i18n/langs/en";
import zhWorkFlow from "../ModuleWorkFlow/i18n/langs/zh";

import enSysBusiness from "../ModuleSysBusiness/i18n/langs/en";
import zhSysBusiness from "../ModuleSysBusiness/i18n/langs/zh";

import enModuleDeviceManage from "../ModuleDeviceManage/i18n/langs/en";
import zhModuleDeviceManage from "../ModuleDeviceManage/i18n/langs/zh";
Vue.use(VueI18n); // 全局注册国际化包

// 准备翻译的语言环境信息
const i18n = new VueI18n({
  locale: localStorage.getItem("i-i18n") || "zh-CN", // 将语言标识存入localStorage或sessionStorage中，页面刷新不会默认中文显示
  messages: {
    // 中文语言包
    "zh-CN": {
      ...zhLocale,
      ...zhPermission,
      ...zhSystem,
      ...zhWorkFlow,
      ...zhSysBusiness,
      ...zhModuleDeviceManage,
    },
    // 英文语言包
    en: {
      ...enLocale,
      ...enPermission,
      ...enSystem,
      ...enWorkFlow,
      ...enSysBusiness,
      ...enModuleDeviceManage,
    },
  },
});
ElementLocale.i18n((key, value) => i18n.t(key, value)); // 为了实现element插件的多语言切换

export default i18n;
